Skip to content

impr: Improve orbit camera to better behave on mouse scroll-wheel#2304

Merged
iwoplaza merged 1 commit intosoftware-mansion:releasefrom
mvanhorn:impr/orbit-camera-scroll-wheel
Apr 12, 2026
Merged

impr: Improve orbit camera to better behave on mouse scroll-wheel#2304
iwoplaza merged 1 commit intosoftware-mansion:releasefrom
mvanhorn:impr/orbit-camera-scroll-wheel

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

Summary

Normalizes WheelEvent.deltaY based on deltaMode in the orbit camera's
wheel event handler. Mouse scroll-wheel events report values ~20x larger
than touchpad events (Chrome: ~100px per notch in pixel mode; Firefox: ~3
in line mode), making zoom extremely jumpy with a mouse.

Changes

apps/typegpu-docs/src/examples/common/setup-orbit-camera.ts

  • Check event.deltaMode and convert line/page deltas to pixel equivalents
  • Clamp the normalized delta to 60 to prevent large discrete jumps from
    mouse wheel notches (Chrome reports deltaMode=0 but deltaY=100)

The touchpad experience is unchanged since touchpad events already use
pixel mode with small delta values (1-5).

Reference: WheelEvent.deltaMode

Fixes #2160

This contribution was developed with AI assistance (Claude Code).

Copilot AI review requested due to automatic review settings March 22, 2026 06:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the docs examples’ orbit camera zoom behavior to be more consistent between touchpads and mouse wheels by normalizing wheel deltas and limiting extreme per-event zoom steps.

Changes:

  • Normalize WheelEvent.deltaY based on event.deltaMode (line/page → pixel-equivalent).
  • Clamp the normalized wheel delta magnitude to reduce large discrete mouse-wheel notch jumps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@iwoplaza iwoplaza changed the base branch from main to release April 12, 2026 09:26
Normalize WheelEvent.deltaY based on deltaMode before passing to
zoomCamera. Mouse wheel events use DOM_DELTA_LINE mode (Firefox) or
report large pixel values (~100 per notch in Chrome), while touchpad
events report small pixel values (~1-5). Without normalization, mouse
wheel zoom jumps are ~20x larger than intended.

The delta is also clamped to 60 to prevent large discrete jumps
regardless of input device or browser behavior.

Fixes software-mansion#2160
@iwoplaza iwoplaza force-pushed the impr/orbit-camera-scroll-wheel branch from 98b254c to 7e32607 Compare April 12, 2026 09:28
Copy link
Copy Markdown
Collaborator

@iwoplaza iwoplaza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@iwoplaza iwoplaza merged commit 384e72e into software-mansion:release Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

impr: Improve orbit camera to better behave on mouse scroll-wheel

3 participants